<?php
$setUpPersonInfoStr = Yii::t('BWeSport', 'set up  person info');
$setUpEmailStr = Yii::t('BWeSport', 'set up email');
$setUpLoginIdStr = Yii::t('BWeSport', 'set up login Id');
$setUpUserNameStr = Yii::t('BWeSport', 'set up user name');
$setUpMobileStr = Yii::t('BWeSport', 'set up mobile');
$loginIdStr = Yii::t('BWeSport', 'Login Id');
$userNameStr = Yii::t('BWeSport', 'User Name');
$emailStr = Yii::t('BWeSport', 'Email');
$mobileStr = Yii::t('BWeSport', 'mobile');
$saveStr = Yii::t('BWeSport', 'Save');
$cancelModifyStr = Yii::t('BWeSport', 'cancel modify');
$cardNumStr = Yii::t('BWeSport', 'card num');
?>
<style>
    .form-signin {
        max-width: 330px;
        padding: 15px;
        margin: 0 auto;
    }
    .form-signin .form-signin-heading,
    .form-signin .checkbox {
        margin-bottom: 10px;
    }
    .form-signin .checkbox {
        font-weight: normal;
    }
    .form-signin .form-control {
        position: relative;
        height: auto;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 10px;
        font-size: 16px;
    }
    .form-signin .form-control:focus {
        z-index: 2;
    }
    .form-signin input[type="email"] {
        margin-bottom: -1px;
        border-bottom-right-radius: 0;
        border-bottom-left-radius: 0;
    }
    .form-signin input[type="password"] {
        margin-bottom: 10px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
</style>
<style>
    .userCard{
        padding-top: 18px;text-align: center;
        font-family: 'Helvetica Neue',sans-serif;
        overflow-x: hidden;
        background: url('http://imgcache.life.qq.com/www/misc/images/wei_webapp_new/bk_repeat1_3.jpg') repeat-y right 0, url('http://imgcache.life.qq.com/www/misc/images/wei_webapp_new/bk_repeat1_2.jpg') repeat-y left 0, url('http://imgcache.life.qq.com/www/misc/images/wei_webapp_new/bk_top1_1.jpg') repeat-x 0 0, url('http://imgcache.life.qq.com/www/misc/images/wei_webapp_new/bk_repeat1_1.jpg') repeat 0 0, #864c2c;
        background-size: 3.5px 23.5px, 3.5px 23.5px, 304.5px 93px, 313px 23.5px;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
    .card{
        width: 267px;
        height: 159px;
        border-radius: 8px;
        text-align: left;
        box-shadow: 0 0 4px rgba(0,0,0,.6);
        margin: 0 auto 0 auto;
        position: relative;
        background: url('http://imgcache.life.qq.com/www/misc/images/wei_webapp_new/card_bk_1.png') no-repeat 0 0;
        background-size: 267px 159px;
    }
    .card .logo {
        max-height: 70px;
        margin: 8px 0 0 3px;
    }
    .card h2 {
        position: absolute;
        top: 3px;
        right: 8px;
        font-size: 9px;
        line-height: 22px;
        text-align: right;
        color: #EDD3BA;
        text-shadow: 1px 1px #A69079;
        margin: 0;
        padding: 0;
    }
    .card .verify {
        display: inline-block;
        height: 40px;
        top: 100px;
        right: 12px;
        text-align: right;
        line-height: 24px;
        color: #92724C;
        font-size: 20px;
        text-shadow: 0 1px rgba(223, 233, 243, .62);
    }
    .pdo {
        position: absolute;
        top: 0;
        left: 0;
        display: inline-block;
    }
    .card .verify span {
        display: inline-block;
        text-align: left;
        color: #92714e;
        text-shadow: 0 1px #f1e7dc;
    }
    .card .verify em {
        display: block;
        line-height: 13px;
        font-size: 10px;
        font-weight: normal;
        font-style: normal;
        color: #92714e;
        text-shadow: 0 1px #f1e7dc;
    }
    .inner>p {
        text-align: center;
        line-height: 36px;
        margin-bottom: 6px;
        min-height: 10px;
        margin: 0;
        padding: 0;
    }
    .inner>p span {
        font-size: 14px;
        color: #646464;
        text-shadow: 0 1px #fff;
        padding-left: 20px;
        display: inline-block;
        background: url('http://imgcache.life.qq.com/www/misc/images/wei_webapp_new/show1.jpg') no-repeat 0 50%;
        -webkit-background-size: 13px 14.5px;
        background-size: 13px 14.5px;
        margin: 0;
        text-align: center;
        line-height: 36px;
    }
    ul.round {
        text-align: left;
        font-size: 14px;
        line-height: 24px;
        overflow: hidden;
        border-radius: 5px;
        border: solid #C2C2C2;
        border-width: 1px 1px 0 1px;
        box-shadow: 0 1px 1px #f6f6f6;
        background-color: #f5f5f5;
        list-style-type: none;
        padding: 0px;
        margin: 0;
        margin-left: 10px;
        margin-right: 10px;
        margin-bottom: 15px;
    }
    .round>li {
        border: solid #C2C2C2;
        border-width: 0 0 1px 0;
        padding: 9px 10px 6px 10px;
        //background: url('http://imgcache.life.qq.com/www/misc/images/wei_webapp_new/icon_power2.png') no-repeat 9px 14px;
        background-size: 24px 21px;
    }
    .round>li>article>a {
        color: #2D2D2D;
        display: block;
        height: 38px;
        line-height: 30px;
        padding-left: 30px;
    }
    .round li.power article>a>p {
        display: inline-block;
        padding-right: 17px;
        text-align: inherit;
        line-height: inherit;
        min-height: 0;
        margin: 0;
        padding: 0;
    }
    #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
    .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
<div id="ajax-loaderdiv" style="display: none;">
    <img src="/billyn-dev/images/ajax-loader.gif" class="ajax-loader">
</div>
<?php
$user = Blyn::app()->getCurrentUser();
$attributes = $user->getAttributes();

$model = new BDynamicFormModel();
$emailField = 'media_email_userInfo';
$userNameField = 'media_userName_userInfo';
$userIdField = 'media_userId_userInfo';
$mobileField = 'media_mobile_userInfo';

$model->addField($emailField);
$model->addField($userNameField);
$model->addField($userIdField);
$model->addField($mobileField);

$model->$emailField = $user->email;
$model->$userNameField = $user->userName;
$model->$userIdField = $user->userId;

$userInfo = $user->getAttribute('userInfo');
$attributes = array();
$mobileAttr = '';
if ($userInfo) {
    $attributes = $userInfo->getChildren();
    foreach ($attributes as $attr) {
        if ($attr->getName() == 'mobile')
            $mobileAttr = $attr->getValue();
        if ($mobileAttr != NULL)
            $model->$mobileField = $mobileAttr;
    }
}
//$mobileAttr = $user->getAttribute('mobile');
//if ($mobileAttr != NULL) {
//    $model->$mobileField = $mobileAttr->getValue();
//}
?>
<div class="userCard" style="text-align: left;">
    <div style="height: 100%;" class="inner">
        <div class="card">
            <img src="<?php echo Yii::app()->request->baseUrl . '/images/BWeSport/11hao.png'; ?>" class="logo">
            <h2><?php echo $user->getId(); ?></h2>
            <strong class="pdo verify"><span style="color:#92714e;text-shadow:0 1px #f1e7dc;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;"><?php echo $cardNumStr; ?></em><?php echo $user->getId(); ?></span></strong>
        </div>
        <?php
        $form = $this->beginWidget('CActiveForm', array(
            "id" => "manage-myInfo-form",
            'enableAjaxValidation' => FALSE,
            'htmlOptions' => array('class' => 'form-signin', 'role' => 'form'),
        ));
        ?>
        <?php
        echo CHtml::label($setUpLoginIdStr . '：', 'userId', array('style' => 'display: none;'));
        echo CHtml::activeTextField($model, $userIdField, array(
            'style' => 'display: none;',
            'class' => 'form-control',
            'placeholder' => $loginIdStr . '...',
            'required' => 'true'));
        echo CHtml::label($setUpUserNameStr . '：', 'userName');
        echo CHtml::activeTextField($model, $userNameField, array(
            'class' => 'form-control',
            'placeholder' => $userNameStr . '...',
            'required' => 'true'));
        echo CHtml::label($setUpMobileStr . '：', 'mobile');
        echo CHtml::activeTextField($model, $mobileField, array(
            'class' => 'form-control',
            'placeholder' => $mobileStr . '...',
            'required' => 'true'));
        echo CHtml::label($setUpEmailStr . '：', 'email');
        echo CHtml::activeTextField($model, $emailField, array(
            'class' => 'form-control',
            'placeholder' => $emailStr . '...', 'required' => 'true', 'autofocus' => 'true'));
        ?>
        <label></label>
        <?php
        echo $control->getAjaxLink(
                array('name' => $saveStr, 'id' => 'BAMemberShipSaveUserInfo'), array(
            'cooker' => 'BAMemberShip@saveUserInfo',
            'htmlOptions' => array(
                'class' => 'btn btn-primary btn-lg btn-block')));
        ?>
        <?php
        echo $control->getAjaxLink(
                array('name' => $cancelModifyStr, 'id' => 'BAMemberShipDisplayUserInfo'), array(
            'cooker' => 'BAMemberShip@showUserInfo',
            'htmlOptions' => array(
                'class' => 'btn btn-info btn-lg btn-block')));
        ?>
        <?php $this->endWidget(); ?>
    </div>
</div>
